package com.jsyh.maidu.presenter;


import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.ExceptionHelper;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.CommentModel;
import com.jsyh.maidu.utils.Utils;
import com.jsyh.maidu.views.CommentView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/6/19.
 */

public class CommentListPreserter extends BasePresenter {

    private String goodsid;
    private String page;
    private CommentView commentv;
    private Context context;

    public CommentListPreserter(CommentView commentv,Context context ,String goodsid,String page)
    {

        this.goodsid=goodsid;
        this.page=page;
        this.commentv=commentv;
        this.context=context;
    }

    public void LoadComment()
    {
        Map<String ,String > params=new HashMap<>();
        params.put("goods_id",goodsid);
        params.put("page",page);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "goods/goods_comments", params, new BaseDelegate.ResultCallback<CommentModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                mLoadingDialog.dismiss();
                Utils.showToast(context, ExceptionHelper.getMessage(e, context));
            }

            @Override
            public void onResponse(CommentModel response, Object tag) {
                commentv.ReCommentList(response);
            }

        });
    }

}
